package com.tanhua.server.exception;

import com.tanhua.model.vo.ErrorResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @auther : 白月尘
 * @date : 13:44  2021/10/17
 */
@ControllerAdvice
public class ExceptionAdvice {
    @ExceptionHandler(Exception.class)
    public ResponseEntity handlerException(Exception e) {
        e.printStackTrace();
        return ResponseEntity.status(500).body(ErrorResult.error());
    }
    @ExceptionHandler(BusinessException.class)
    public ResponseEntity handlerException(BusinessException e) {
        e.printStackTrace();
        ErrorResult errorResult = e.getErrorResult();
        return ResponseEntity.status(500).body(errorResult);
    }
}
